Skip to content

Improvements on rbtree_best_fit::check_sanity - #282

Merged
igaztanaga merged 1 commit into
boostorg:developfrom
MiguelCompany:improve_check_sanity
Sep 1, 2026
Merged

Improvements on rbtree_best_fit::check_sanity#282
igaztanaga merged 1 commit into
boostorg:developfrom
MiguelCompany:improve_check_sanity

Conversation

@MiguelCompany

@MiguelCompany MiguelCompany commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

When checking the sanity of a shared memory segment, if the memory has been corrupted, the iterator might read outside the segment, producing a segfault.

This was found during the investigation of eProsima/Fast-DDS#6501

The proposed changes perform the quick check on the header before the loop.
Inside the loop, the check for the alignment is performed before accessing the data pointed to by the iterator, and the loop returns early whenever the accumulated free_memory value exceeds the limit.

This reduces the chance of the iterator jumping to an offset outside the segment.

Perform quick tests before iterating on the blocks.
Early exit from loop if block size is 0 or accumulated free memory exceeds maximum.

Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
@igaztanaga
igaztanaga merged commit 73d3ef4 into boostorg:develop Sep 1, 2026
61 checks passed
@igaztanaga

Copy link
Copy Markdown
Member

Many thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants